﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media;

namespace Zero.UControl.Component
{
    public class CalendarDay : INotifyPropertyChanged
    {
        public DateTime Date { get; set; }
        public string Day { get; set; }
        public string Lunar { get; set; }
        public string Festival { get; set; }
        public bool IsCurrentMonth { get; set; }
        public string TagText { get; set; } // “休”、“班”
        public Brush TagColor { get; set; }
        public Brush Foreground { get; set; }
        public Brush Background { get; set; }

        private Brush borderBrush = new SolidColorBrush((Color) ColorConverter.ConvertFromString("#E0E0E0"));
        public Brush BorderBrush 
        {
            get => borderBrush;
            set
            {
                if(borderBrush != null)
                {
                    borderBrush = value;
                    PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(BorderBrush)));
                }
            }
        }

        private Thickness borderThickness = new Thickness(1);
        public Thickness BorderThickness 
        {
            get => borderThickness;
            set
            {
                if(borderThickness != value)
                {
                    borderThickness = value;
                    PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(BorderThickness)));
                }
            }
        }

        public bool IsToDay { get; set; }
        public bool IsFestivalDay { get; set; }
        private bool _isSelected;
        public bool IsSelected
        {
            get => _isSelected;
            set
            {
                if (IsToDay) return;
                if (_isSelected != value)
                {
                    _isSelected = value;
                    PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(IsSelected)));
                    if (value)
                    {
                        BorderThickness = new Thickness(2);
                        BorderBrush = IsFestivalDay ? new SolidColorBrush(Color.FromRgb(212, 57, 0)) : Brushes.Orange;
                    }
                    else
                    {
                        BorderThickness = new Thickness(1);
                        BorderBrush = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#E0E0E0"));
                    }
                }
            }
        }

        public event PropertyChangedEventHandler? PropertyChanged;
    }
}
